
package org.come.mouslisten;

import com.tool.Stall.Commodity;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.BoothBoxJpanel;
import org.come.baitan.BaiTanJpanel;
import org.come.entity.Goodstable;
import org.come.entity.RoleSummoning;
import org.come.until.MessagrFlagUntil;

public class ChoseGoodsStallMouslisten implements MouseListener {
    private int type;
    private int index;
    private BoothBoxJpanel boxJpanel;
    private Goodstable goodstable;
    private RoleSummoning roleSummoning;
    private int[] xy;
    private BaiTanJpanel baiTanJpanel;
    public ChoseGoodsStallMouslisten(int index, int type, BoothBoxJpanel boxJpanel) {
        this.type = type;
        this.index = index;
        this.boxJpanel = boxJpanel;
    }

    public ChoseGoodsStallMouslisten(final int index, final int type, final BaiTanJpanel boxJpanel, final int[] xy) {
        this.type = type;
        this.index = index;
        this.baiTanJpanel = boxJpanel;
        this.xy = xy;
    }
    @Override
    public void mouseClicked(MouseEvent e) {
      /*  Commodity commodity = this.boxJpanel.getStall().getCommodity(this.type, this.index);
        if (commodity != null) {
            this.boxJpanel.XZBuy(commodity);
        }*/
        int i=0;
        for (RoleSummoning roleSummoning:baiTanJpanel.petrolesulist.keySet()){
            if (i==index){
                MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
                baiTanJpanel.XZBuy(roleSummoning);
                baiTanJpanel.PaintingText(index,true);
            }
            i++;
        }

    }

    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
      /*  Commodity commodity = this.boxJpanel.getStall().getCommodity(this.type, this.index);
        if (commodity != null) {
            Goodstable good = commodity.getGood();
            RoleSummoning pet = commodity.getPet();
            if (good != null) {
                ZhuFrame.getZhuJpanel().creatgoodtext(good);
            } else if (pet != null) {
                ZhuFrame.getZhuJpanel().creatpettext(pet);
            }
        }*/
        int i=0;
        if (baiTanJpanel==null)return;
        for (RoleSummoning roleSummoning:baiTanJpanel.petrolesulist.keySet()){
            if (i==index){
                MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
                ZhuFrame.getZhuJpanel().creatpettext(roleSummoning);
                baiTanJpanel.PaintingText(index,true);
            }
            i++;
        }

    }

    @Override
    public void mouseExited(MouseEvent e) {
        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
        if (baiTanJpanel==null)return;
        baiTanJpanel.ClearText();
       /* if (this.type == 0) {
            ZhuFrame.getZhuJpanel().cleargoodtext();
        } else if (this.type == 1) {
            ZhuFrame.getZhuJpanel().pettext();
        }*/

    }

    public Goodstable getGoodstable() {
        return this.goodstable;
    }

    public void setGoodstable(Goodstable goodstable) {
        this.goodstable = goodstable;
    }

    public RoleSummoning getRoleSummoning() {
        return this.roleSummoning;
    }

    public void setRoleSummoning(RoleSummoning roleSummoning) {
        this.roleSummoning = roleSummoning;
    }
}
